package com.sjn.util.encrytion;

/**
 * 求模加密,将字符强转为int类进行求模运算
 */

public class ModuloEncryption extends AddEncryption{
    public ModuloEncryption(DataEncryption dataEncryption) {
        super(dataEncryption);
    }

    @Override
    public String encryption() {
        byte[] by = getDataEncryption().getData().getBytes();
        int[] st = new int[by.length];
        for(int i=0;i<by.length;i++){
            //进行求模运算
            st[i] = (int)by[i]%71;
            //求模完成立即赋值回去
            by[i] = (byte)st[i];
        }
        getDataEncryption().setData(new String(by));
        return getDataEncryption().getData();
    }
}
